#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int b;
	double cost=8;
	cin>>a>>b;
	if(b<=3) cout<<"cost=8.0";
	else
	{
		cost+=a=='A'?(b-3)*1.5:(b-3)*2;
		printf("cost=%.1f",cost);
	}
    return 0;
}
